package com.softroad.help.app.ui;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import com.softroad.help.app.AppManager;
import com.softroad.help.app.R;
import com.softroad.help.app.login.LoginActivity;

/**
 * 
 * @brief 程序启动页面
 * @author Fanhao.Yi
 * @date 2015年5月4日上午9:43:41
 * @version V1.0
 */
public class LauncherActivity extends BaseActivity {
	/**
	 * 上下文对象
	 */
	private Context mInstance;

	public static void startActivity(Context context) {
		context.startActivity(new Intent(context, LauncherActivity.class));
	}

	@Override
	public int bindLayout() {
		// 设置无标题
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		// 设置全屏
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		return R.layout.activity_launcher;
	}

	@Override
	public void initView(View view) {

		// 添加动画效果
		AlphaAnimation animation = new AlphaAnimation(0.3f, 1.0f);
		animation.setDuration(4000);
		animation.setAnimationListener(new AnimationListener() {

			@Override
			public void onAnimationStart(Animation animation) {

			}

			@Override
			public void onAnimationRepeat(Animation animation) {

			}

			@Override
			public void onAnimationEnd(Animation animation) {
				if (mApplication.isLogin()) {
					MainActivity.startActivity(getContext());
				} else {
					LoginActivity.startActivity(getContext());
				}
				AppManager.getAppManager().finishActivity();
			}
		});
		view.setAnimation(animation);

	}

	@Override
	public void initData(Context mContext) {
		mInstance = mContext;
	}

	@Override
	public void initListener() {

	}

	@Override
	public void resume() {

	}

	@Override
	public void destroy() {

	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

}
